<!--  -->
<template>
  <div class="goods-item flex" @click.stop="goodsTo(item.id,item.goods_id)">
    <slot name="orderHead"></slot>
    <div class="flex">
      <div class="img" :class="[className === 'classify'?'min-img':'']">
        <van-image
          width="90px"
          height="90px"
          :src="item && item.goods && item.goods.thumb"
          radius="8px"
          v-if="className !=='classify'"
        />
        <van-image
          width="80px"
          height="80px"
          :src="item.thumb"
          radius="8px"
          v-else
        />
      </div>
      <div class="wrap flex" 
        :class="[className==='covert'|| className === 'present'?'covert-flex':'',className==='order'|| className==='classify'?'order-flex':'']">
        <div class="flex-j-sb title">
          <h3 class="ell" v-if="className=== 'classify'">{{item.title}}</h3>
          <h3 class="ell" v-else>{{item && item.goods && item.goods.title || item && item.goods_name}}</h3>
          <slot name="amount"></slot>
        </div>
        <slot name="orderSum"></slot>
        <slot name="convertBtn"></slot>
        <slot name="member"></slot>
        <slot name="classify"></slot>
      </div>
    </div>
    <slot name="orderAddress"></slot>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';
import { Image as VanImage } from "vant";
export default {
name:'',
props:{
  item:{
    type:Object,
    default:() => {
      return {}
    }
  },
  className:String,
  goodIndex:Number,
},
//import引入的组件需要注入到对象中才能使用
components: {
  VanImage
},
data() {
return {

};
},
//监听属性 类似于data概念
computed: {},
//监控data中的数据变化
watch: {},
//方法集合
methods: {
  goodsTo(id,goodsid) {
    if(this.className === 'classify' && id) {
      this.$router.push(this.fun.getUrl('goods', {id:id}, {}));
    }
    if(this.className === 'covert' && goodsid) {
      this.$router.push(this.fun.getUrl('goods', {id:goodsid}, {}));
    }
  },
},
//生命周期 - 创建完成（可以访问当前this实例）
created() {

},
//生命周期 - 挂载完成（可以访问DOM元素）
mounted() {

},
beforeCreate() {}, //生命周期 - 创建之前
beforeMount() {}, //生命周期 - 挂载之前
beforeUpdate() {}, //生命周期 - 更新之前
updated() {}, //生命周期 - 更新之后
beforeDestroy() {}, //生命周期 - 销毁之前
destroyed() {}, //生命周期 - 销毁完成
activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
}
</script>
<style lang="scss" scoped>
.ell {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.covert-flex {
  flex-direction: column;
  justify-content:space-between;
}
/* @import url(); 引入公共css类 */
  .goods-item {
    background-color: #fff;
    padding:12px;
    border-radius: 8px 8px 8px 8px;
    margin: 0 0 10px 0;
    flex-direction: column;
    .orderHead {
      font-size: 14px;
      font-weight: 400;
      padding: 0 0 10px 0;
      h3 {
        color: #00001C;
        font-weight: 400;
      }
      p {
        color: var(--themeBaseColor);
      }
    }
    .order-sum {
      padding:17px 0 0 0;
      font-size: 13px;
      font-weight: 400;
      color: #00001C;
      .price {
        font-weight: 500;
      }
    }
    .img {
      min-width: 90px;
      height: 90px;
    }
    .min-img {
      min-width: 80px;
      height: 80px;
    }
    .wrap {
      width: 100%;
      box-sizing: border-box;
      padding:0 0 0 10px;
      flex-direction: column;
      h3 {
        word-break:break-all;
        word-wrap:break-word;
        text-align: left;
        font-weight: 500;
        color: #00001C;
      }
      .sum {
        min-width: 20%;
        font-size: 13px;
        font-weight: 400;
        color: #00001C;
        text-align: right;
      }
    }
    .order-flex {
      justify-content:center;
    }
    .order-address {
      text-align: left;
      font-size: 13px;
      font-weight: 400;
      color: #6E6E79;
      padding:15px 0 0 0;
      .member-info {
        padding:0 0 8px 0;
      }
    }
    .address-btn {
      padding:12px 0 0 0;
      justify-content: flex-end;
      .btn {
        font-size: 13px;
        line-height: 13px;
        font-weight: 400;
        color:#fff;
        color: var(--themeBaseColor);
        padding:9px 14px;
        border-radius: 25px 25px 25px 25px;
        border: 1px solid var(--themeBaseColor);
        box-sizing: border-box;
        margin-left: 10px;
      }
    }
    .classify {
      padding:10px 0 0 0;
      align-items: flex-end;
      .price {
        color:#F15353;
        font-weight: 500;
        font-size: 16px;
        span {
          font-size: 12px;
        }
      }
      .select {
        background: #F15353;
        border-radius: 50%;
        padding:5px 6px;
        .icon-gouwuche2 {
          color:#fff;
          font-size: 13px;
        }
      }
    }
  }
</style>